package cn.tedu.cwfw.fos.service.impl;

import cn.tedu.cwfw.fos.pojo.dto.FosQuery;
import cn.tedu.cwfw.fos.pojo.vo.FosVo;
import cn.tedu.cwfw.fos.service.FosService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import cn.tedu.cwfw.fos.mapper.FosMapper;

import java.util.Collections;
import java.util.List;

@Transactional
@Service
@Slf4j
public class FosServiceImpl implements FosService {
    @Autowired
    private FosMapper fosMapper;

    @Override
    public List<FosVo> findFos(FosQuery fosQuery) {
        log.debug("查询所有店铺信息:{}", fosQuery);
        List<FosVo> fosVos = fosMapper.findFos(fosQuery);
        return fosVos;
    }

    @Override
    public void addShop(FosVo fosVo) {
        log.debug("添加店铺信息:{}", fosVo);
        fosMapper.addShop(fosVo);
        log.debug("添加店铺信息成功");
    }

    @Override
    public void delete(Long id) {
        log.debug("删除店铺信息:{}", id);
        fosMapper.delete(id);
        log.debug("删除店铺信息成功");
    }

    @Override
    public void update(FosVo fosVo) {
        log.debug("修改店铺信息:{}", fosVo);
        fosMapper.update(fosVo);
        log.debug("修改店铺信息成功");
    }

    @Override
    public FosVo findById(Long id) {
        log.debug("根据id查询店铺信息:{}", id);
        FosVo fosVo = fosMapper.findById(id);
        return fosVo;
    }
}
